add support for gemini thinking input params#1058
Merged
VisargD merged 4 commits intoApr 25, 2025
Merged
Conversation
VisargD
approved these changes
Apr 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Author Description
Summary By MatterAI
🔄 What Changed
This PR adds support for the 'thinking' input parameter for Gemini models in both Google and Google Vertex AI providers. The implementation allows passing a 'thinking' configuration that enables the model to include its thought process in responses and set a token budget for this feature.
🔍 Impact of the Change
This enhancement enables users to leverage Gemini's thinking capabilities through the gateway, allowing for more transparent AI reasoning and decision-making processes. The feature is implemented by transforming the 'thinking' parameter into the appropriate configuration format required by Google's APIs.
📁 Total Files Changed
src/providers/google-vertex-ai/chatComplete.tssrc/providers/google-vertex-ai/transformGenerationConfig.tssrc/providers/google/chatComplete.tssrc/types/requestBody.ts🧪 Test Added
No explicit tests were added in this PR. Manual testing should be performed to verify the functionality of the Gemini thinking parameter in both Google and Google Vertex AI providers.
🔒 Security Vulnerabilities
No security vulnerabilities were identified in the changes.
Motivation
To enable users to access Gemini's thinking capabilities through the gateway, providing more transparency in AI reasoning and decision-making processes.
Type of Change
How Has This Been Tested?
Screenshots (if applicable)
N/A
Checklist
Related Issues
N/A
Quality Recommendations
Add type safety for the thinking parameter by using a more specific type than Record<string, any> for thinkingConfig
Add validation for the thinking.budget_tokens parameter to ensure it's a positive number
Add unit tests to verify the transformation of the thinking parameter
Add documentation comments explaining the thinking parameter functionality
Sequence Diagram
sequenceDiagram participant Client participant Gateway participant RequestBody as RequestBody Types participant GoogleProvider as Google Provider participant VertexAIProvider as Google Vertex AI Provider participant GoogleAPI as Google API participant VertexAI as Google Vertex AI Client->>Gateway: Request with thinking parameter Gateway->>RequestBody: Validate thinking parameter Note over RequestBody: Added thinking interface<br/>with type and budget_tokens alt Google Provider Gateway->>GoogleProvider: Forward request GoogleProvider->>GoogleProvider: transformGenerationConfig() Note over GoogleProvider: Transform thinking parameter<br/>include_thoughts: true<br/>thinking_budget: params.thinking.budget_tokens GoogleProvider->>GoogleAPI: API call with thinking_config GoogleAPI-->>GoogleProvider: Response with thinking details GoogleProvider-->>Gateway: Processed response else Google Vertex AI Provider Gateway->>VertexAIProvider: Forward request VertexAIProvider->>VertexAIProvider: transformGenerationConfig() Note over VertexAIProvider: Transform thinking parameter<br/>include_thoughts: true<br/>thinking_budget: params.thinking.budget_tokens VertexAIProvider->>VertexAI: API call with thinking_config VertexAI-->>VertexAIProvider: Response with thinking details VertexAIProvider-->>Gateway: Processed response end Gateway-->>Client: Final response